package jmine.tec.batch.context;

import java.util.HashMap;
import java.util.Map;

/**
 * Represents a batch execution context.
 */
public class BatchExecutionContext {

    private final Map<String, Object> attributes = new HashMap<String, Object>();

    /**
     * analogo a {@link Map#get(Object)}
     * 
     * @param key String
     * @return Object
     */
    public Object getAttribute(String key) {
        return this.attributes.get(key);
    }

    /**
     * analogo a {@link Map#put(Object, Object)}
     * 
     * @param key String
     * @param value Object
     */
    public void setAttribute(String key, Object value) {
        this.attributes.put(key, value);
    }

    /**
     * analogo a {@link Map#remove(Object)}
     * 
     * @param key String
     */
    public void removeAttribute(String key) {
        this.attributes.remove(key);
    }

    /**
     * analogo a {@link Map#clear()}
     */
    public void clear() {
        this.attributes.clear();
    }

    /**
     * Adiciona todos os atributos do contexto dado. Analogo a {@link Map#putAll(Map)}
     * 
     * @param context contexto
     */
    public void addAll(BatchExecutionContext context) {
        this.attributes.putAll(context.attributes);
    }
}
